<?php

class dataBase {
    //private $uid;
    //private $username;
    //private $password;
    //private $sAns;
    //private $sQut;

    /**
     * @assert ("123") == 1
     * @assert ("") == 0
    */
   
    public function checkName($username)
    {
       //require_once('conn.php');

        $result = mysql_query("select * from account where username='$username'");
        if(mysql_fetch_assoc($result)){
                return false;
        }
        else{
               return true;
        }
    }
    /**
     * @assert ("123","123") == 1
     * @assert ("","") == 0
    */    
    public function checkLogin($username, $password)    //not work but can test
    {
        //require('conn.php');
        $host = "localhost";
	$user = "root";
	$password = "111";
        $connect = mysql_connect($host, $user, $password);
	$db = "votingSystem";
        mysql_select_db($db, $connect);
        mysql_query("set names utf8");
	
        $uidArr = mysql_query("select uid from account where username='$username' and password='$password'");
	if(mysql_fetch_assoc($uidArr)){
            return true;
        }
	else{
            return false;
	}
    }
}
?>